package com.itheima.ydd.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.ydd.entity.SysMenu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SysMenuMapper extends BaseMapper<SysMenu> {

    //查询角色下所属菜单
    @Select("SELECT m.* FROM sys_menu m JOIN sys_role_menu rm ON rm.role_id = #{role_id} AND rm.menu_id = m.id WHERE m.pid = #{id}")
    List<SysMenu> selectMenu(@Param("role_id") String role_id, @Param("id") int id);

    //查询所有菜单
    @Select("select * from sys_menu sm where sm.pid = #{pid}")
    List<SysMenu> selectByPid(int pid);
}
